package cn.webrx;


import java.util.Calendar;

public class Ex1_2 {
    public static void main(String[] args) {
        //分时问候  实例化日历类，c就对象，我用的是日历类的对象
        Calendar c = Calendar.getInstance();
        c.set(Calendar.HOUR_OF_DAY, 13);
        c.set(Calendar.MINUTE, 30);
        int hour = c.get(Calendar.HOUR_OF_DAY);
        //6-8 早上
        //8-12 上午
        //12-14中午
        //14-18下午
        if (hour >= 6 && hour < 8) {
            System.out.println("早上好");
        } else if (hour >= 8 && hour < 12) {
            System.out.println("上午好");
        } else if (hour >= 12 && hour < 14) {
            System.out.println("中午好");
        } else if (hour >= 14 && hour < 18) {
            System.out.println("下午好");
        } else if (hour >= 18 && hour < 23) {
            System.out.println("晚上好");
        } else if (hour >= 23 || hour < 1) {
            System.out.println("夜深了，请注意身体.");
        } else if (hour >= 1 && hour < 3) {
            System.out.println("午夜.");
        } else {
            System.out.println("凌晨.");

        }
    }

    public static void ex2() {
        int year = 2024;
        if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) {
            System.out.printf("%d:闰年%n", year);
        } else {
            System.out.printf("%d:平年%n", year);
        }
    }

    public static void ex1() {
        int year = 2024;
        if (year % 400 == 0) {
            System.out.printf("%d:闰年%n", year);
        } else if (year % 4 == 0 && year % 100 != 0) {
            System.out.printf("%d:闰年%n", year);
        } else {
            System.out.printf("%d:平年%n", year);
        }
    }
}
